package com.example.springbootdemo;

import com.example.springbootdemo.text.en.SplitWordUtil;
import org.wltea.analyzer.core.IKSegmenter;
import org.wltea.analyzer.core.Lexeme;

import java.io.IOException;
import java.io.StringReader;

public class IkanalyzerExample {

    public static void main(String[] args) {
//        String text = "The cat, sat on the mat. The dog sat on the mat.";
        String text = "alarm:[[Dhgate-scheduler]TIME: 09-21 10:15. ENV: dhpay-hk, SCHEDULE: Paycenter-Acct-SettleGoodCamel, JOB: Paycenter-Acct-SettleGoodCamel. ALARM: Dispatch Job Fail!],";
        text = text.replaceAll("-", " ");

        // 创建 IKSegmenter 对象
        IKSegmenter ikSegmenter = new IKSegmenter(new StringReader(text), true);

        // 分词
        try {
            Lexeme lexeme;
            while ((lexeme = ikSegmenter.next()) != null) {
                System.out.println(lexeme.getLexemeText());
            }
        } catch (IOException e) {
            e.printStackTrace();
        }

        System.out.println(SplitWordUtil.split(text));
    }
}